<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    h1 {
      /* 禁止选中文字*/
      user-select: none;
      -webkit-user-select: none;
      -moz-user-select: none; 
      -o-user-select: none;
      -ms-user-select: none;
    }
  </style>
  <script src="./js/react.min.js"></script>
  <script src="./js/react-dom.min.js"></script>
  <script src="./js/babel.js"></script>

</head>
<body>
  <div id="example"></div>
  <script type="text/babel">
    class MyComponent extends React.Component {
     constructor(props) {
       super(props)
       this.state = {
         islike: true
       }
       this.changeLike = this.changeLike.bind(this)
     }
     changeLike(event) {
     
       this.setState({
         islike: !this.state.islike
       })
     }
      render() {
        let msg = this.state.islike? '我喜欢你': '你喜欢我'
        return <h1 onClick={this.changeLike}>{msg}</h1>
      }
    }
  ReactDOM.render(<MyComponent/>, document.getElementById('example'))
  </script>
</body>
</html>